<?php
namespace App\Listener;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

use App\Job\UserPrizeJob;
use App\Job\UserAllPrizeJob;

/**
 * @Listener 
 */
class PrizeListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            \App\Event\UserPay\StatusOkEvent::class,
        ];
    }
    
    // 各种奖项
    public function process($event)
    {
        // 直推奖
        (new UserPrizeJob)->push($event->user->user_id, $event->money, '【' . $event->user->username . '】的消费补贴');
        
        // 团队奖
        // 复投没有团队奖
        if(!$event->repeat)
        {
            (new UserAllPrizeJob)->push($event->user->user_id, $event->money, '【' . $event->user->username . '】的团队奖励');
        }
    }
}